{{ header }}{{ column_left }}
<div id="content">
  <div class="page-header">
    <div class="container-fluid">
      <div class="float-end">
        <button type="submit" form="form-banner" data-bs-toggle="tooltip" title="{{ button_save }}" class="btn btn-primary"><i class="fas fa-save"></i></button>
        <a href="{{ back }}" data-bs-toggle="tooltip" title="{{ button_back }}" class="btn btn-light"><i class="fas fa-reply"></i></a></div>
      <h1>{{ heading_title }}</h1>
      <ol class="breadcrumb">
        {% for breadcrumb in breadcrumbs %}
          <li class="breadcrumb-item"><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
        {% endfor %}
      </ol>
    </div>
  </div>
  <div class="container-fluid">
    <div class="card">
      <div class="card-header"><i class="fas fa-pencil-alt"></i> {{ text_form }}</div>
      <div class="card-body">
        <form id="form-banner" action="{{ save }}" method="post" data-oc-toggle="ajax">
          <div class="row mb-3 required">
            <label for="input-name" class="col-sm-2 col-form-label">{{ entry_name }}</label>
            <div class="col-sm-10">
              <input type="text" name="name" value="{{ name }}" placeholder="{{ entry_name }}" id="input-name" class="form-control"/>
              <div id="error-name" class="invalid-feedback"></div>
            </div>
          </div>
          <div class="row mb-3">
            <label for="input-status" class="col-sm-2 col-form-label">{{ entry_status }}</label>
            <div class="col-sm-10">
              <select name="status" id="input-status" class="form-select">
                <option value="1"{% if status %} selected{% endif %}>{{ text_enabled }}</option>
                <option value="0"{% if not status %} selected{% endif %}>{{ text_disabled }}</option>
              </select>
            </div>
          </div>
          <br/>
          <ul class="nav nav-tabs" id="language">
            {% for language in languages %}
              <li class="nav-item"><a href="#language-{{ language.language_id }}" data-bs-toggle="tab" class="nav-link{% if languages.index == 0 %} active{% endif %}"><img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}"/> {{ language.name }}</a></li>
            {% endfor %}
          </ul>
          <div class="tab-content">
            {% set image_row = 0 %}
            {% for language in languages %}
              <div id="language-{{ language.language_id }}" class="tab-pane{% if languages.index == 0 %} active{% endif %}">
                <table id="image-{{ language.language_id }}" class="table table-bordered table-hover">
                  <thead>
                    <tr>
                      <td class="text-left required">{{ entry_title }}</td>
                      <td class="text-start">{{ entry_link }}</td>
                      <td class="text-center">{{ entry_image }}</td>
                      <td class="text-end">{{ entry_sort_order }}</td>
                      <td></td>
                    </tr>
                  </thead>
                  <tbody>
                    {% if banner_images[language.language_id] %}
                      {% for banner_image in banner_images[language.language_id] %}
                        <tr id="image-row-{{ image_row }}">
                          <td class="text-start">
                            <input type="text" name="banner_image[{{ language.language_id }}][{{ image_row }}][title]" value="{{ banner_image.title }}" placeholder="{{ entry_title }}" id="input-banner-image-{{ language.language_id }}-{{ image_row }}-title" class="form-control"/>
                            <div id="error-banner-image-{{ language.language_id }}-{{ image_row }}-title" class="invalid-feedback"></div>
                          </td>
                          <td class="text-start" style="width: 30%;"><input type="text" name="banner_image[{{ language.language_id }}][{{ image_row }}][link]" value="{{ banner_image.link }}" placeholder="{{ entry_link }}" id="input-banner-image-{{ language.language_id }}-{{ image_row }}-link" class="form-control"/></td>
                          <td class="text-center">
                            <div class="card">
                              <img src="{{ banner_image.thumb }}" alt="" title="" id="thumb-image-{{ image_row }}" data-oc-placeholder="{{ placeholder }}" class="card-img-top"/> <input type="hidden" name="banner_image[{{ language.language_id }}][{{ image_row }}][image]" value="{{ banner_image.image }}" id="input-banner-image-{{ language.language_id }}-{{ image_row }}-image"/>
                              <div class="card-body">
                                <button type="button" data-oc-toggle="image" data-oc-target="#input-image-{{ image_row }}" data-oc-thumb="#thumb-image-{{ image_row }}" class="btn btn-primary btn-sm btn-block"><i class="fas fa-pencil-alt"></i> {{ button_edit }}</button>
                                <button type="button" data-oc-toggle="clear" data-oc-target="#input-image-{{ image_row }}" data-oc-thumb="#thumb-image-{{ image_row }}" class="btn btn-warning btn-sm btn-block"><i class="fas fa-trash-alt"></i> {{ button_clear }}</button>
                              </div>
                            </div>
                          </td>
                          <td class="text-end" style="width: 10%;"><input type="text" name="banner_image[{{ language.language_id }}][{{ image_row }}][sort_order]" value="{{ banner_image.sort_order }}" placeholder="{{ entry_sort_order }}" id="input-banner-image-{{ language.language_id }}-{{ image_row }}-sort-order" class="form-control"/></td>
                          <td class="text-end"><button type="button" onclick="$('#image-row-{{ image_row }}, .tooltip').remove();" data-bs-toggle="tooltip" title="{{ button_remove }}" class="btn btn-danger"><i class="fas fa-minus-circle"></i></button></td>
                        </tr>
                        {% set image_row = image_row + 1 %}
                      {% endfor %}
                    {% endif %}
                  </tbody>
                  <tfoot>
                    <tr>
                      <td colspan="4"></td>
                      <td class="text-end"><button type="button" id="button-banner-{{ language.language_id }}" data-language="{{ language.language_id }}" data-bs-toggle="tooltip" title="{{ button_banner_add }}" class="btn btn-primary"><i class="fas fa-plus-circle"></i></button></td>
                    </tr>
                  </tfoot>
                </table>
              </div>
            {% endfor %}
          </div>
          <input type="hidden" name="banner_id" value="{{ banner_id }}" id="input-banner-id"/>
        </form>
      </div>
    </div>
  </div>
</div>
<script type="text/javascript"><!--
var image_row = {{ image_row }};

$('button[id^=\'button-banner\']').on('click', function() {
    var element = this;

    html = '<tr id="image-row-' + image_row + '">';
    html += '  <td class="text-start"><input type="text" name="banner_image[' + $(element).attr('data-language') + '][' + image_row + '][title]" value="" placeholder="{{ entry_title }}" id="input-banner-image-' + $(element).attr('data-language') + '-' + image_row + '-title" class="form-control"/>';
    html += '    <div id="error-banner-image-' + $(element).attr('data-language') + '-' + image_row + '-title" class="invalid-feedback"></div></td>';
    html += '  <td class="text-start"><input type="text" name="banner_image[' + $(element).attr('data-language') + '][' + image_row + '][link]" value="" placeholder="{{ entry_link }}" class="form-control"/></td>';
    html += '  <td class="text-center">';
    html += '    <div class="card">';
    html += '      <img src="{{ placeholder }}" alt="" title="" id="thumb-image-' + image_row + '" data-oc-placeholder="{{ placeholder }}" class="card-img-top"/>';
    html += '      <input type="hidden" name="banner_image[' + $(element).attr('data-language') + '][' + image_row + '][image]" value="" id="input-image-' + image_row + '"/>';
    html += '      <div class="card-body">';
    html += '        <button type="button" data-oc-toggle="image" data-oc-target="#input-image-' + image_row + '" data-oc-thumb="#thumb-image-' + image_row + '" class="btn btn-primary btn-sm btn-block"><i class="fas fa-pencil-alt"></i> {{ button_edit }}</button>';
    html += '        <button type="button" data-oc-toggle="clear" data-oc-target="#input-image-' + image_row + '" data-oc-thumb="#thumb-image-' + image_row + '" class="btn btn-warning btn-sm btn-block"><i class="fas fa-trash-alt"></i> {{ button_clear }}</button>';
    html += '      </div>';
    html += '    </div>';
    html += '  </td>';
    html += '  <td class="text-end"><input type="text" name="banner_image[' + $(element).attr('data-language') + '][' + image_row + '][sort_order]" value="" placeholder="{{ entry_sort_order }}" id="input-banner-image-' + $(element).attr('data-language') + '-' + image_row + '-sort-order" class="form-control"/></td>';
    html += '  <td class="text-end"><button type="button" onclick="$(\'#image-row-' + image_row + ', .tooltip\').remove();" data-bs-toggle="tooltip" title="{{ button_remove }}" class="btn btn-danger"><i class="fas fa-minus-circle"></i></button></td>';
    html += '</tr>';

    $('#image-' + $(element).attr('data-language') + ' tbody').append(html);

    image_row++;
});
//--></script>
{{ footer }} 